Credit scheduler for ordering the execution of tasks

ABSTRACT

A method for scheduling the execution of tasks on a processor is disclosed. The purpose of the method is in part to serve the special needs of soft real-time tasks, which are time-sensitive. A parameter Δ is an estimate of the amount of time required to execute the task. Another parameter Γ is the maximum amount of time that the task is to spend in a queue before being executed. In the illustrative embodiment, the preferred wait time Γ i  for a newly-arrived task T i  is expected to be met though the insertion of the newly-arrived task T i  into a position k in a queue such that position k respects the task&#39;s preferred wait time Γ i  in light of the expected execution times of the other tasks already in the queue.

CROSS REFERENCE TO RELATED APPLICATIONS

This application claims the benefit of U.S. provisional application No. 61/232,542, filed Aug. 10, 2009, entitled “Supporting Soft Real-Time Virtual Machines.” The concepts, but not necessarily the nomenclature, of this provisional application are hereby incorporated by reference.

Furthermore, this application claims the benefit of U.S. provisional application No. 61/254,019, filed Oct. 22, 2009, entitled “Supporting Soft Real-Time Virtual Machines.” The concepts, but not necessarily the nomenclature, of this provisional application are hereby incorporated by reference.

FIELD OF THE INVENTION

The present invention relates to data processing systems in general, and, more particularly, to credit schedulers for ordering the execution of tasks on a processor.

BACKGROUND OF THE INVENTION

When two or more operating systems operate on one piece of hardware, the processes associated with each operating system contend for the hardware that is available. Without something to mediate their access, one operating system's processes could monopolize or over-use the hardware to the detriment of the other operating system's processes. Therefore, a program sits between the operating systems and the hardware to act as a mediator. This program is commonly known as a “hypervisor.”

One of the jobs performed by the hypervisor is scheduling the order of execution of tasks associated with each operating system. This is not an easy job. Some tasks are time sensitive (e.g., tasks associated with input or output, speech processing, video processing, transmission or reception of signals, etc.) and some tasks are non-time-sensitive or are less-time-sensitive. Whatever the mix of time-sensitive and non-time-sensitive tasks, the respective operating systems are always presenting to the hypervisor tasks to be performed, and if the hypervisor does not wisely choose the order for executing those tasks, the performance of the entire system can be degraded.

The portion of a hypervisor that determines the order for executing the tasks is called a “scheduler.” Schedulers in the prior art, however, do not always choose wisely, and, therefore, the need exists for an improved scheduler.

SUMMARY OF THE INVENTION

The present invention enables the scheduling of the execution of tasks on a processor without some of the costs and disadvantages associated with schedulers in the prior art. The purpose of the present invention is in part to serve the special needs of soft real-time tasks, which are time-sensitive. In the illustrative embodiment, the scheduler analyzes the time-sensitive needs of a task that is to be queued. The scheduler inserts the task into a position in the queue based on the amount of time that the task is to spend in the queue relative to other tasks already queued.

The present invention defines a parameter Γ, which is the amount of time that a newly-arrived task is to spend in a queue before being executed. The expected execution time of the tasks already queued is one of the parameters relevant to the position that the newly-arrived task will receive in the queue. By using these parameters—and others—some embodiments of the present invention are able to schedule the execution of tasks without some of the costs and disadvantages for doing so in the prior art.

The illustrative embodiment comprises:

-   -   receiving at a queue for execution on a processor a task T_(i),         wherein the task T_(i), has a first estimated execution time         Δ_(i) and a first preferred wait time Γ_(i), and wherein the         queue comprises at least one other task with a position j and an         estimated execution time Δ_(j); and

inserting the task T_(i) into the queue at a position k, wherein j≦k, such that:

$\Gamma_{i} \geq {\sum\limits_{j = 1}^{k - 1}\Delta_{j}}$ and ${\Gamma_{i} < {\sum\limits_{j = 1}^{k}\Delta_{j}}};$

wherein j=1 represents the position at the head of the queue.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 depicts a block diagram of the salient components of data processing system 100.

FIG. 2 depicts a flowchart of the salient steps performed by data processing system 100 in accordance with the illustrative embodiment of the present invention.

FIG. 3 depicts a flowchart of the salient sub-steps performed by data processing system 100 in performing step 201 in accordance with the illustrative embodiment.

FIG. 4 depicts a flowchart of the salient sub-steps performed by data processing system 100 in performing step 202 in accordance with the illustrative embodiment.

DETAILED DESCRIPTION

For the purposes of this specification, the term “processor” is defined as a physical computing resource that is capable of executing a task.

For the purposes of this specification, the term “task” is defined as at least one operation performed by a processor.

FIG. 1 depicts a block diagram of the salient components of data processing system 100. Data processing system 100 is a machine that comprises: receiver 101, queue 102, scheduler 103, processor 104, and transmitter 105.

Although the illustrative embodiment comprises one receiver 101 and one transmitter 105, it will be clear to those skilled in the art, after reading this disclosure, how to make and use alternative embodiments of the present invention that comprise any number of receivers (e.g., two receivers, three receivers, four receivers, etc.) and any number of transmitters (e.g., one transmitter, two transmitters, three transmitters, four transmitters, etc.).

Although the illustrative embodiment comprises one scheduler 103, it will be clear to those skilled in the art, after reading this disclosure, how to make and use alternative embodiments of the present invention that comprise any number of schedulers (e.g., one scheduler, two schedulers, three schedulers, four schedulers, etc.).

Although the illustrative embodiment comprises one queue 102, it will be clear to those skilled in the art, after reading this disclosure, how to make and use alternative embodiments of the present invention that comprise any number of queues (e.g., one queue, two queues, three queues, four queues, etc.).

Although the illustrative embodiment comprises one processor 104, it will be clear to those skilled in the art after reading this disclosure how to make and use alternative embodiments of the present invention that comprise any number of processors (e.g., one processor, two processors, three processors, four processors, etc.).

Receiver 101 is hardware that receives a temporal succession of tasks to be executed by processor 104 and provides those tasks to queue 102. It will be clear to those having ordinary skill in the art, after reading the present disclosure, that in alternative embodiments of the present invention receiver 101 can be software or a combination of software and hardware.

For purposes of the present disclosure, each task is identified by T_(i) wherein i is an integer that represents the relative order of arrival of the task at receiver 101 with respect to other tasks. For example, task T_(i) arrived at receiver 101 immediately before task T_(i+1), wherein i is an integer.

In accordance with the illustrative embodiment, each task arrives at receiver 101 with an estimated execution time Δ parameter. For the purposes of this specification, the phrase “estimated execution time Δ_(i)” of a task T_(i) is defined as an estimate of the amount of time required to execute task T_(i). In accordance with the illustrative embodiment, each task T_(i) received by receiver 101 is accompanied by an estimated execution time Δ_(i) parameter, but it will be clear to those skilled in the art, after reading this disclosure, how to make and use alternative embodiments of the present invention in which some or all of the tasks are not accompanied by an estimated execution time Δ_(i) parameter. In those cases, it will be clear to those skilled in the art, after reading this disclosure, how to make and use alternative embodiments of the present invention in which data processing system 100 generates the estimated execution time Δ_(i) parameter for one or more tasks.

In the illustrative embodiment of the present invention, the estimated execution time parameter Δ for a task is the actual execution time of that task during the task's previous execution cycle on processor 104. It will be clear to those having ordinary skill in the art, after reading the present disclosure, how to make and use alternative embodiments of the present invention in which the estimated execution time parameter Δ is based on an average of actual execution times recorded for previous execution cycles of the task, or in which the estimated execution time parameter Δ is based on another scheme devised by those implementing the present invention.

In accordance with the illustrative embodiment, each task T_(i) is either a time-sensitive task or a non-time-sensitive task. In accordance with the illustrative embodiment, each time-sensitive task arrives at receiver 101 with a preferred wait time Γ_(i) parameter. For the purposes of this specification, the phrase “preferred wait time Γ_(i)” of task T_(i) is defined as the maximum amount of time that the task is to spend in a queue before being executed.

It will be clear to those skilled in the art, after reading this disclosure, how to make and use receiver 101.

Queue 102 is hardware that holds each task T_(i) and its accompanying parameters, while the task awaits execution by processor 104. It will be clear to those having ordinary skill in the art, after reading the present disclosure, that in alternative embodiments of the present invention queue 102 can be software or a combination of software and hardware. In the illustrative embodiment, each task that is already in queue 102, has a “queue index j,” wherein j is an integer that represents the relative order in which tasks are lined up in the queue, i.e., j is the position in queue of those tasks that have already been queued. In the illustrative embodiment, processor 104 selects the task at the head of the queue to be executed next. For the purposes of this specification, the head of the queue is defined as having queue index j=1. The queue index j is to be distinguished from the relative order of arrival i.

The position into which a newly-arrived task is inserted in queue 102 is determined by the present invention. For the purposes of this specification, “position k” is defined as a position in queue 102 into which scheduler 103 inserts a newly-arrived task T_(i) at the time of arrival. The position k is to be distinguished from the relative order of arrival i and from the position index j of tasks that we previously queued. When a newly-arrived task T_(i) is inserted into queue 102, it may be positioned ahead of tasks that are already queued, thus shifting their respective queue indices j. In general: 1≦k≦j+1  (Eq. 1) for all integer values of j≧1, wherein j=1 represents the position at the head of the queue.

For example, Table 1 depicts an illustrative example of queue 102 at time t=0:

TABLE 1 Example of Tasks in Queue 102 Estimated Execution Preferred Queue Index J Time Δ_(i) Wait Time Γ_(i) In Queue 102 Task T_(i) (in msec) (in msec) 1 T₂ 9  5 2 T₁ 9 200 3 T₃ 5 250 . . . . . . . . . . . . 43  T₄₃ 8 225 The estimated execution time Δ_(i), the preferred wait time Γ_(i), and the queue index j for each task in queue 102 are provided to scheduler 103 for analysis. In the illustrative embodiment shown in Table 1 above, Task T₂, having arrived after task T₁, was placed in queue 102 ahead of task T₁, because the preferred wait time Γ of task T₂ (5 msec) is more urgent than the expected execution time Δ of Task T₁ (9 msec). This method is explained in more detail in regards to FIG. 3 below.

It will be clear to those skilled in the art, after reading this disclosure, how to make and use queue 102.

Scheduler 103 is hardware and software that is capable of performing the functionality described in this disclosure and in the accompanying figures. It will be clear to those having ordinary skill in the art, after reading the present disclosure, how to make alternative embodiments of the present invention in which scheduler 103 is exclusively hardware, or exclusively software. For example, when scheduler 103 receives the estimated execution time Δ_(i), the preferred wait time Γ_(i) for a newly arrived task at queue 102, and the queue index j for each task in queue 102, scheduler 103 analyzes the data and selects a specific position k in queue 102 into which to insert the task relative to the queue index j of those tasks already in queue 102.

In accordance with the illustrative embodiment, scheduler 103 is a “credit” scheduler, but it will be clear to those skilled in the art, after reading this disclosure, how to make and use alternative embodiments of the present invention in which scheduler 103 is not a “credit” scheduler. The XEN® hypervisor is an example of a hypervisor that comprises a credit scheduler, but it will be clear to those having ordinary skill in the art, after reading the present disclosure, that alternative embodiments of the present invention can use a different hypervisor. Furthermore, it will be clear to those skilled in the art that alternative well-known names for a hypervisor include, but are not limited to, a “virtual machine monitor” (VMM).

Processor 104 is hardware that executes tasks from queue 102 in the order determined by scheduler 103. It will be clear to those having ordinary skill in the art, after reading the present disclosure, that in alternative embodiments of the present invention processor 104 can be software or a combination of software and hardware. It will be clear to those skilled in the art how to make and use processor 104. In accordance with the illustrative embodiment of the present invention, processor 104 comprises one core, but it will be clear to those skilled in the art, after reading this disclosure, how to make and use alternative embodiments of the present invention in which processor 104 comprises multiple cores. Furthermore, it will be clear to those skilled in the art that alternative names for a processor include, but are not limited to, a “core” or “CPU.”

Transmitter 105 is hardware that transmits the results of each task execution. It will be clear to those skilled in the art how to make and use transmitter 105. It will be clear to those having ordinary skill in the art, after reading the present disclosure, that in alternative embodiments of the present invention transmitter 105 can be software or a combination of software and hardware.

FIG. 2 depicts a flowchart of the salient steps performed by data processing system 100 in accordance with the illustrative embodiment of the present invention.

At step 201, a temporal succession of tasks is received at receiver 101, analyzed by scheduler 103, and placed into queue 102. In accordance with the illustrative embodiment, each task T_(i) arrives at receiver 101 with an estimated execution time Δ_(i) parameter. For each task T_(i) that is time sensitive, a preferred wait time Γ_(i) parameter is also received. Step 201 is described in greater detail below and in the accompanying figures.

In some embodiments of the present invention, whether a task is treated as a time-sensitive task depends on whether it arrives from a time-sensitive or a non-time-sensitive “domain.” For purposes of this specification, a “domain” is defined as software that is an operating system or an application using the operating system that comprises tasks to be executed by processor 104. Because multiple domains can co-exist in processing system 101 and each domain requires execution of the tasks it comprises on processor 104, whether a domain is time sensitive affects the treatment of its constituent tasks. A voice processing application is an example of a time-sensitive domain. Thus, any task from the voice processing application would be characterized as time sensitive and treated accordingly by scheduler 103. It will be clear to those having ordinary skill in the art, after reading the present disclosure, how to make and use alternative embodiments of the present invention that use domains.

At step 202, processor 104 accesses queue 102 and executes the queued tasks. Step 202 is described in greater detail below and in the accompanying figures.

In accordance with the illustrative embodiment, steps 201 and 202 are continually-running asynchronous processes that operate independently of each other. However, it will be clear to those skilled in the art, after reading this disclosure, how to make and use alternative embodiments of the present invention in which steps 201 and 202 are not independent.

FIG. 3 depicts a flowchart of the salient sub-steps performed by data processing system 100 in performing step 201 in accordance with the illustrative embodiment.

At step 301, a task T_(i) arrives at receiver 101 for queuing at queue 102 in a manner well-known in the art.

At step 302, scheduler 103 computes position k for task T_(i) into which position k scheduler 103 will insert task T_(i) in accordance with the present invention.

In the illustrative embodiment, the preferred wait time Γ_(i) for a newly-arrived task T_(i) is expected to be met though the insertion or emplacement of the newly-arrived task T_(i) into a position k in queue 102 such that position k respects the task's preferred wait time Γ_(i) in light of the expected execution times of the other tasks already in queue 102.

A minimum value of k is computed for a newly-arrived task T_(i) such that:

$\begin{matrix} {\Gamma_{i} \geq {\sum\limits_{j = 1}^{k - 1}\Delta_{j}}} & \left( {{Eq}.\mspace{14mu} 2} \right) \\ {and} & \; \\ {\Gamma_{i} < {\sum\limits_{j = 1}^{k}\Delta_{j}}} & \left( {{Eq}.\mspace{14mu} 3} \right) \end{matrix}$ where j=1 represents the head of the queue, and where Δ_(j) represents the expected execution time of the task queued at position j.

At step 303, task T_(i) is inserted into queue 102 at position k counting from the head of the queue. The process continues indefinitely as more tasks arrive at receiver 101.

In the illustrative embodiment, a task T_(i), once placed into a position in queue 102, is not re-positioned, except insofar as a subsequent task T_(n), where n>i, may be placed in a position in queue 102 ahead of T_(i). A newly-arrived task may receive a position ahead of other queued tasks depending on the sum of the expected execution times of the already-queued tasks as compared to the preferred wait time for the newly-arrived task.

It should be noted that in some embodiments of the present invention, the expected execution time Δ_(i) of newly-arrived task T_(i) is not material to the calculation of position k for task T_(i). Furthermore, it will be clear to those having ordinary skill in the art, after reading the present disclosure, that the use of the preferred wait time parameter Γ is for those tasks that are time sensitive or otherwise categorized as soft-real-time tasks. Likewise, for a domain categorized as time sensitive or soft-real-time, the tasks it comprises also are treated as time-sensitive with a respective preferred execution time parameter Γ.

It will be clear to those having ordinary skill in the art, after reading the present disclosure, that in alternative embodiments of the present invention, a task T_(i+1) with a preferred wait time Δ_(i+1) will be executed on processor 104 ahead of an already queued task T_(i) when Γ_(i+1)<Δ_(i), because positioning a newly-arrived task ahead of an already-queued task based on the preferred wait time of the newly-arrived task results, in the illustrative embodiment, in its being executed before an earlier-arrived task already in queue 102.

It will be clear to those having ordinary skill in the art, after reading the present disclosure, that generally, a newly-arrived task goes to the end of queue 102 by default, unless the preferred wait time parameter Γ overrules this arrangement under the conditions and circumstances described above.

It will be clear to those having ordinary skill in the art, after reading the present disclosure, how to enable step 201 of the present invention.

FIG. 4 depicts a flowchart of the salient sub-steps performed by data processing system 100 in performing step 202 in accordance with the illustrative embodiment.

At step 401, processor 104 accesses queue 102 to select the next task for execution in a manner well-known in the art.

At step 402, processor 104 selects the task at the head of the queue for execution, in accordance with the illustrative embodiment. In the illustrative embodiment, position 1 represents the head of the queue, but it will be clear to those having ordinary skill in the art, after reading the present disclosure, how to make and use alternative embodiments of the present invention in which processor 104 selects the next task from any queue such that the selection meets the criteria described above for honoring the preferred wait time Γ_(i) of task T_(i). It will be clear to those having ordinary skill in the art, after reading the present disclosure, how to enable step 402.

At step 403, processor 104 executes the selected task. How to execute a queued task at a processor is well-known in the art.

It is understood that this disclosure teaches just some examples of how the tasks of processing system 100 are ordered and organized and that many different variations can be devised by those skilled in the art after reading this disclosure. The scope of the present invention is to be determined by the following claims. 

1. A method comprising: receiving at time t_(i) at a queue for execution on a processor a first task T₁, wherein the first task T₁ has a first estimated execution time Δ_(i), and a first preferred wait time Γ_(i), and wherein the queue comprises at least one other task with a position j and an estimated execution time Δ_(j); receiving at time t₂ at the queue for execution on the processor a second task T₂ for execution on the processor, wherein time t_(i) is before time t₂, and wherein the second task T₂ has a second estimated execution time Δ_(m) and a second preferred wait time Γ₂; inserting the first task T₁ into the queue at a position k, wherein j≦k, such that: $\Gamma_{i} \geq {\Delta_{m} + {\sum\limits_{j = 1}^{k - 1}\Delta_{j}}}$ and ${\Gamma_{i} < {\Delta_{m} + {\sum\limits_{j = 1}^{k}\Delta_{j}}}};$  and executing the second task T₂ on the processor before executing the first task T₁ when Γ₂<Δ_(i), wherein j=1 represents the position at the head of the queue.
 2. The method of claim 1 wherein the first task T_(i) is a time-sensitive task.
 3. The method of claim 1 wherein the position k is independent of the first estimated execution time Δ_(i).
 4. The method of claim 1 wherein a time-sensitive domain comprises the first task T₁.
 5. The method of claim 1 further comprising: executing on the processor the task at the head of the queue with the position j=1.
 6. The method of claim 5 wherein the first task T₁ is a time-sensitive task.
 7. The method of claim 6 wherein the position k is independent of the first estimated execution time Δ_(i).
 8. The method of claim 5 wherein a time-sensitive domain comprises the first task T₁.
 9. The method of claim 8 wherein the position k is independent of the first estimated execution time Δ_(i).
 10. The method of claim 1 wherein the second task T₂ is a time-sensitive task.
 11. The method of claim 10 wherein the order of execution of the first task T₁ and the second task T₂ is independent of the second estimated execution time Δ₂.
 12. The method of claim 1 wherein a time-sensitive domain comprises the second task T₂.
 13. The method of claim 12 wherein the order of execution of the first task T₁ and the second task T₂ is independent of the second estimated execution time Δ₂.
 14. A method comprising: receiving at a queue for execution on a processor a first task T_(i), wherein the first task T_(i) has a first estimated execution time Δ_(i) and a first preferred wait time Γ_(i), and wherein the queue comprises at least one other task with a position j and an estimated execution time Δ_(j); inserting the first task T_(i) into the queue at a position k, wherein j≦k, such that: $\Gamma_{i} \geq {\sum\limits_{j = 1}^{k - 1}\Delta_{j}}$ and ${\Gamma_{i} < {\sum\limits_{j = 1}^{k}\Delta_{j}}},$ wherein j=1 represents the position at the head of the queue; and executing the first task T_(i) on the processor before executing a second task T_(n) when Γ_(i)<Δ_(n), wherein the first task T_(i), was received at the queue after the second task T_(n), and wherein the second task T_(n) has a second estimated execution time Δ_(n).
 15. The method of claim 14 wherein the first task T_(i), is a time-sensitive task.
 16. The method of claim 15 wherein the order of execution of the first task T_(i), and the second task T_(n) is independent of the first estimated execution time Δ_(i).
 17. The method of claim 14 wherein a time-sensitive domain comprises the first task T_(i).
 18. The method of claim 17 wherein the order of execution of the first task T_(i), and the second task T_(n) is independent of the first estimated execution time Δ_(i). 